package com.leo.oplayer.filter;

import java.util.Calendar;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.leo.oplayer.service.CheckAlarm;

public class BootCompletedReceiver extends BroadcastReceiver{

	@Override
	public void onReceive(Context context, Intent intent) {
		
		Log.d("Oplay", "BootCompletedReceiver onReceive !");
		
		//启动定时检查
		Calendar c = Calendar.getInstance();
		
		 /* 指定闹钟设置时间到时要运行CallAlarm.class */
        Intent i = new Intent(context,CheckAlarm.class);
        
        PendingIntent sender = PendingIntent.getBroadcast(context,1, i, 0);
        /* setRepeating()可让闹钟重复运行 */
        AlarmManager am;
        
        //设置运行时间
        c.setTimeInMillis(System.currentTimeMillis());
        c.set(Calendar.HOUR_OF_DAY,18);
        c.set(Calendar.MINUTE,0);
        c.set(Calendar.SECOND,0);
        c.set(Calendar.MILLISECOND,0);
        
        //间隔时间
        int times= 24*60*60*1000;
        am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        am.setRepeating(AlarmManager.RTC_WAKEUP,
                  c.getTimeInMillis(),times,sender);
		
	}

}
